module Analyzer.D.lexical.identifiersLex;

import Analyzer.D.lexical.token_tables;
import Analyzer.D.util.textScanner;
import Analyzer.D.lexical.token_enum;
import Analyzer.D.lexical.numbers;
import std.uni;

public TOK scanIdentifier( TextScanner sc )
{
    char[] ident = "";

    while( isIdentifierPart( sc.peek() ) )
    {
        ident ~= sc.read();
    }
    
    if( isKeyword( ident ) )
    {
        return getTokenOfKeyword( ident );
    }
    else
    {
        return TOK.Identifier;
    }
}

public bool isIdentifierStart( char c )
{
    return isUniAlpha(c) || c == '_';
}

public bool isIdentifierPart( char c )
{
    return isUniAlpha(c) || isDigit(c) || c == '_';
}